package com.youlai.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.model.entity.SysCheckItem;
import com.youlai.system.model.entity.SysRegisteredItem;
import com.youlai.system.model.query.RegisteredPageQuery;
import com.youlai.system.service.SysRegisteredItemService;
import com.youlai.system.mapper.SysRegisteredItemMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86177
* @description 针对表【sys_registered_item】的数据库操作Service实现
* @createDate 2024-08-27 11:06:29
*/
@Service
public class SysRegisteredItemServiceImpl extends ServiceImpl<SysRegisteredItemMapper, SysRegisteredItem>
    implements SysRegisteredItemService{

    @Override
    public IPage<SysRegisteredItem> listPagedRegistereds(RegisteredPageQuery query) {
        IPage<SysRegisteredItem> page = new Page<>(query.getPageNum(), query.getPageSize());
        QueryWrapper<SysRegisteredItem> wrapper = new QueryWrapper<>();
        if (query.getRegItemName() != null) {
            wrapper.like("reg_item_name", query.getRegItemName());
        }
        if(query.getStatus() != null){
            wrapper.eq("status", query.getStatus());
        }
        return this.page(page, wrapper);
    }

    @Override
    public List<SysRegisteredItem> getEnabledCheckItem() {
        QueryWrapper<SysRegisteredItem> wrapper = new QueryWrapper<>();
            wrapper.like("status", 1);
        return this.list(wrapper);
    }
}




